package com.bhs.sansonglogistics.utils;

import static java.util.regex.Pattern.matches;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.text.InputFilter;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansonglogistics.base.BaseActivity;
import com.bhs.sansonglogistics.base.Constants;
import com.bhs.sansonglogistics.bean.LoginBean;
import com.bhs.sansonglogistics.net.NetCallBack;
import com.bhs.sansonglogistics.ui.adapter.PictureSelectAdapter;
import com.bhs.sansonglogistics.ui.enterprise.EnterpriseCertificationActivity;
import com.bhs.sansonglogistics.ui.home.MainActivity;
import com.bhs.sansonglogistics.ui.login.RealNameAuthenticationActivity;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.luck.picture.lib.entity.LocalMedia;
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import cn.jpush.android.api.JPushInterface;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import top.zibin.luban.CompressionPredicate;
import top.zibin.luban.Luban;
import top.zibin.luban.OnCompressListener;

public class MyUtils {
    /**
     * 屏幕高度
     *
     * @return the height of screen, in pixel
     */
    public static int getScreenHeight(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Point point = new Point();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            //noinspection ConstantConditions
            wm.getDefaultDisplay().getRealSize(point);
        } else {
            //noinspection ConstantConditions
            wm.getDefaultDisplay().getSize(point);
        }
        return point.y;
    }

    /**
     * 屏幕宽度
     *
     * @return the width of screen, in pixel
     */
    public static int getScreenWidth(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Point point = new Point();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            //noinspection ConstantConditions
            wm.getDefaultDisplay().getRealSize(point);
        } else {
            //noinspection ConstantConditions
            wm.getDefaultDisplay().getSize(point);
        }
        return point.x;
    }

    /**
     * 交货方式
     */
    public static String getDeliveryType(int type) {
        return type == 1 ? "自送专线" : "上门提货";
    }

    /**
     * 订单类型
     */
    public static String getOrderType(int type) {
        return type == 1 ? "指派下单" : "极速下单";
    }

    /**
     * 订单类型
     */
    public static String getOrderType2(int type, int orderType) {

        String placeOrder = type == 1 ? "指派" : "极速";
        String efficiency = orderType == 1 ? "普运" : "快运";
        return placeOrder + efficiency;
    }

    /**
     * 配送方式
     */
    public static String getDistributionType(int type) {
        return type == 1 ? "送货上门" : "自提";
    }


    /**
     * 配送方式
     *
     * @param type
     * @return
     */
    public static String getHaulageTime(int type, int max, int min) {
        switch (type) {
            case 1:
                return String.format("普运/%s-%s天", min, max);
            case 2:
                return String.format("快运/%s-%s天", min, max);
            default:
                return "商议";
        }
    }


    public static String getSexName(int type) {
        switch (type) {
            case 0:
                return "女";
            case 1:
                return "男";
            default:
                return "未设置";
        }
    }

    public static String getReceiptType(int type) {
        switch (type) {
            case 1:
                return "无需";
            case 2:
                return "回单";
            default:
                return "收条";
        }
    }

    public static String isInvoice(int type) {
        return "";
        // return type == 1 ? "开发票" : "不开发票";
    }

    /**
     * 获取支付状态
     *
     * @return 0=待支付 1货主已申请支付  2支付完成（物流公司已确认） 3异常或取消 pays
     */
    public static String getPayStatus(String money, String noPay, int type, int pay_method) {
        switch (type) {
            case 0:
                if (!TextUtils.isEmpty(noPay)) {
                    return String.format("%s(%s)", noPay, pay_method == 1 ? "待支付" : "到付");
                } else {
                    return String.format("%s(%s)", money, pay_method == 1 ? "待支付" : "到付");
                }
            case 1:
                return "货主已申请支付";
            case 2:
                return String.format("%s(支付完成)", money);
            default:
                return "异常或取消";
        }
    }

    public static String getStatusType(int type) {
        switch (type) {
            case 0:
                return "等待验证";
            case 1:
                return "已同意";
            default:
                return "拒绝";
        }
    }

    public static void setText(TextView textView, String text) {
        textView.setText(TextUtils.isEmpty(text) ? "" : text);
    }

    /**
     * 拨打电话（直接拨打电话）
     * @param phoneNum 电话号码
     */
    /**
     * 拨打电话（跳转到拨号界面，用户手动点击拨打）
     *
     * @param phoneNum 电话号码
     */
    public static void callPhone(Context activity, String phoneNum) {
        Intent intent = new Intent(Intent.ACTION_DIAL);
        Uri data = Uri.parse("tel:" + phoneNum);
        intent.setData(data);
        activity.startActivity(intent);
    }

    public static boolean isEmpty(List<?> list) {
        return list == null || list.size() == 0;
    }


    //隐藏输入法
    public static void hideSoftInputWindow(Activity context, View view) {
        InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    public static void imageUpload(BaseActivity activity, ArrayList<LocalMedia> result, NetCallBack callBack, int requestCode) {
        MultipartBody.Builder builder = new MultipartBody.Builder();
        File file = new File(result.get(0).getRealPath());
        Luban.with(activity).load(file).ignoreBy(100).setTargetDir(activity.getExternalCacheDir().getPath()).filter(new CompressionPredicate() {
            @Override
            public boolean apply(String path) {
                return !(TextUtils.isEmpty(path) || path.toLowerCase().endsWith(".gif"));
            }
        }).setCompressListener(new OnCompressListener() {
            @Override
            public void onStart() {
                // TODO 压缩开始前调用，可以在方法内启动 loading UI
            }

            @Override
            public void onSuccess(File file) {
                // TODO 压缩成功后调用，返回压缩后的图片文件
                RequestBody imageBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
                builder.addFormDataPart("file", file.getName(), imageBody);
                builder.addFormDataPart("upload_file", "customer");
                builder.addFormDataPart("type", "app");
                List<MultipartBody.Part> parts = builder.build().parts();
                activity.loadingPopupShow();
                activity.networkRequest(activity.netApi.imageUpload(parts), callBack, requestCode);
            }

            @Override
            public void onError(Throwable e) {
                // TODO 当压缩过程出现问题时调用
            }
        }).launch();

    }

    public static void fileUpload(BaseActivity activity, File file, NetCallBack callBack, int requestCode) {
        MultipartBody.Builder builder = new MultipartBody.Builder();
        RequestBody imageBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
        builder.addFormDataPart("file", file.getName(), imageBody);
        builder.addFormDataPart("upload_file", "customer");
        builder.addFormDataPart("type", "app");
        List<MultipartBody.Part> parts = builder.build().parts();
        activity.networkRequest(activity.netApi.imageUpload(parts), callBack);

    }

    public static void fileUpload(BaseActivity activity, File file, NetCallBack callBack, int requestCode, boolean isCover) {
        MultipartBody.Builder builder = new MultipartBody.Builder();
        RequestBody imageBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
        builder.addFormDataPart("file", file.getName(), imageBody);
        builder.addFormDataPart("upload_file", "customer");
        builder.addFormDataPart("type", "app");
        List<MultipartBody.Part> parts = builder.build().parts();
        activity.networkRequest(activity.netApi.imageUpload(parts, "cover"), callBack);

    }

    /**
     * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
     */
    public static int dip2px(Context context, float dpValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }

    //登录复用
    public static void login(Activity activity, LoginBean loginBean) {
        if (loginBean.isStatus()) {
            SharedPreferencesUtils.saveString(activity, "token", loginBean.getData().getUser().getLogin_token());
            SharedPreferencesUtils.saveString(activity, "uid", loginBean.getData().getUser().getUnid());
            SharedPreferencesUtils.saveInt(activity, "logistics_id", loginBean.getData().getUser().getLogistics_id());
            SharedPreferencesUtils.saveString(activity, "face", loginBean.getData().getUser().getHeaderpic());
            SharedPreferencesUtils.saveString(activity, "phone", loginBean.getData().getUser().getMobile());
            SharedPreferencesUtils.saveString(activity, "nickname", loginBean.getData().getUser().getNickname());
            SharedPreferencesUtils.saveString(activity, "invite_code", loginBean.getData().getUser().getInvite_code());
            JPushInterface.setAlias(activity, 1, loginBean.getData().getUser().getJpush_alias());
            if (loginBean.getData().getUser().getLogistics_id() > 0) {
                activity.startActivity(new Intent(activity, MainActivity.class));
            } else {
                activity.startActivity(new Intent(activity, EnterpriseCertificationActivity.class));
            }
            activity.finish();
        } else {
            ToastUtil.show(loginBean.getMsg());
        }
    }


    public static String getStatusMsg(int status, String particulars, int DeliveryType, int DistributionType) {
        switch (status) {
            case 5:
                if (DeliveryType == 1) {
                    return "待货主交货，请尽快与货主联系，让货主自送专线";
                } else {
                    return "待提货，请尽快与货主联系，上门提货";
                }
            case 7:
                return "已入库";
            case 9:
                return "运输中";
            case 11:
                return DistributionType == 1 ? "待交货" : "待提货";
            case 15:
                return "待确认";
            case 20:
                return "已完成";
            case 80:
                return String.format("已拒绝(%s)", particulars);
            case 99:
                return "已取消";
            case 13:
                return "待回单";
            default:
                return "查看";
        }
    }

    public static boolean isPhone(String str) {
        String regex = "^(1)\\d{10}$";//正则表达式
        return str.matches(regex);
    }

    public static boolean isCarnumberNO(String carnumber) {
        /*
         * 车牌号格式：汉字 + A-Z + 5位A-Z或0-9 （只包括了普通车牌号，教练车和部分部队车等车牌号不包括在内）
         */
        String carnumRegex = "[\u4e00-\u9fa5]{1}[A-Z]{1}[A-Z_0-9-挂]{5,6}";//在正则表达
        if (TextUtils.isEmpty(carnumber)) return false;
        else return carnumber.matches(carnumRegex);
    }

    //禁止输入表情
    public static InputFilter[] inputFilters(Context context, int Length) {
        return new InputFilter[]{new InputFilter() {
            Pattern emoji = Pattern.compile("[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]", Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);

            @Override
            public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
                Matcher emojiMatcher = emoji.matcher(source);

                if (emojiMatcher.find()) {
                    Toast.makeText(context, "不支持输入表情", Toast.LENGTH_SHORT).show();
                    //  MyToast.showText("不支持输入表情");
                    return "";
                }
                return null;
            }

        }, new InputFilter() {
            @Override
            public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
                for (int i = start; i < end; i++) {
                    int type = Character.getType(source.charAt(i));
                    if (type == Character.SURROGATE || type == Character.OTHER_SYMBOL) {
                        Toast.makeText(context, "不支持输入表情", Toast.LENGTH_SHORT).show();
                        return "";
                    }
                }
                return null;
            }
        },
                /**这里限制输入的长度为200*/
                new InputFilter.LengthFilter(Length)};
    }


    //验证银行卡号
    public static boolean checkBankCard(String cardId) {
        char bit = getBankCardCheckCode(cardId.substring(0, cardId.length() - 1));
        if (bit == 'N') {
            return false;
        }
        return cardId.charAt(cardId.length() - 1) == bit;
    }

    //从不含校验位的银行卡卡号采用 Luhm 校验算法获得校验位
    public static char getBankCardCheckCode(String nonCheckCodeCardId) {
        if (nonCheckCodeCardId == null || nonCheckCodeCardId.trim().length() == 0 || !nonCheckCodeCardId.matches("\\d+")) {
            //如果传的不是数据返回N
            return 'N';
        }
        char[] chs = nonCheckCodeCardId.trim().toCharArray();
        int luhmSum = 0;
        for (int i = chs.length - 1, j = 0; i >= 0; i--, j++) {
            int k = chs[i] - '0';
            if (j % 2 == 0) {
                k *= 2;
                k = k / 10 + k % 10;
            }
            luhmSum += k;
        }
        return (luhmSum % 10 == 0) ? '0' : (char) ((10 - luhmSum % 10) + '0');
    }

    /**
     * 将本地图片转成Bitmap
     *
     * @param path 已有图片的路径
     * @return
     */
    public static Bitmap openImage(String path) {
        Bitmap bitmap = null;
        try {
            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(path));
            bitmap = BitmapFactory.decodeStream(bis);
            bis.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bitmap;
    }

    /**
     * 小数点为0的修改为整数 其他不变
     * Created by xul on 2017/3/3.
     */
    public static String checkPoint(String num) {
        StringBuilder myNum = new StringBuilder();
        try {
            String integerNum = num.substring(0, num.indexOf("."));
            String decimals = num.substring(num.indexOf("."), num.length());
            float decimalsNum = Float.valueOf(decimals);
            if (decimalsNum > 0) {
                myNum = myNum.append(integerNum).append(decimals);
            } else {
                myNum = myNum.append(integerNum);
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return String.valueOf(myNum);
    }

    /**
     * 小数点为0的修改为整数 其他不变
     * Created by xul on 2017/3/3.
     */
    public static String checkPoint(double value) {
        String num = String.valueOf(value);
        StringBuilder myNum = new StringBuilder();
        try {
            String integerNum = num.substring(0, num.indexOf("."));
            String decimals = num.substring(num.indexOf("."), num.length());
            float decimalsNum = Float.valueOf(decimals);
            if (decimalsNum > 0) {
                myNum = myNum.append(integerNum).append(decimals);
            } else {
                myNum = myNum.append(integerNum);
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return String.valueOf(myNum);
    }

    /**
     * 水印
     *
     * @param path
     * @return
     */
    public static String watermark(String path) {
        return path;
    }


    /**
     * 手机号中间四位隐藏
     *
     * @param phone 手机号
     */
    public static String phoneHide(String phone) {
        String phoneHide = phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
        return phoneHide;
    }

    public static String getCNCardType(int cardType) {
        switch (cardType) {
            case 1:
                return "储蓄卡";
            case 2:
                return "信用卡";
            case 3:
                return "准贷记卡";
            case 4:
                return "预支付卡";
            default:
                return "未知卡";
        }
    }

    public static String getCNCardTypeName(String cardType) {
        if (TextUtils.isEmpty(cardType)) return null;
        switch (cardType) {
            case "储蓄卡":
                return "1";
            case "信用卡":
                return "2";
            case "准贷记卡":
                return "3";
            case "预支付卡":
                return "4";
            default:
                return "未知卡";
        }
    }

    public static String getPayType(int type) {
        switch (type) {
            case 1:
                return "微信";
            case 2:
                return "支付宝";
            default:
                return "银行卡";
        }
    }

    public static String getEmberShipDays(int type, int promoteType, int time) {
        if (type == 1) {
            return String.format("会员到期：%s", getDayHour(time));
        } else {
            if (promoteType > 0 && promoteType < 5) {
                return String.format("金卡到期：%s", getDayHour(time));
            } else if (promoteType > 5) {
                return String.format("银卡到期：%s", getDayHour(time));
            } else {
                return "";
            }
        }
    }

    public static String getPromotionType(int promoteType) {
        if (promoteType > 0 && promoteType < 5) {
            return "金卡";
        } else if (promoteType > 5) {
            return "银卡";
        } else {
            return "";
        }

    }

    public static String getDayHour(int time) {
        long unixTime = System.currentTimeMillis() / 1000L;
        int dayTimestamp = 60 * 60 * 24;
        time = time - (int) unixTime;
        int day = time / dayTimestamp;
        int hourTimestamp = time % dayTimestamp;
        int hour = hourTimestamp / (60 * 60);
        LogUtils.d(time + "===" + time % dayTimestamp);
        return String.format("%s天%s时", day, hour);
    }

    public static String getDay(int time) {
        long unixTime = System.currentTimeMillis() / 1000L;
        int dayTimestamp = 60 * 60 * 24;
        time = time - (int) unixTime;
        int day = time / dayTimestamp;
        return String.format("%s天", day);
    }

    public static String getPayType(String type) {
        switch (type) {
            case "1":
                return "余额支付";
            case "3":
                return "微信支付";
            case "4":
                return "支付宝支付";
            default:
                return "未知";
        }
    }


    public static String getText(String text) {
        return TextUtils.isEmpty(text) ? "" : text;
    }

    /**
     * 使用java正则表达式去掉多余的.与0
     *
     * @param s
     * @return
     */
    public static String subZeroAndDot(String s) {
        if (s.indexOf(".") > 0) {
            s = s.replaceAll("0+?$", "");//去掉多余的0
            s = s.replaceAll("[.]$", "");//如最后一位是.则去掉
        }
        return s;
    }

    public static String getBefore(int timestamp) {
        if (DateUtils.getRelativeTimeSpanString(timestamp * 1000L).toString().startsWith("0")) {
            return "刚刚";
        } else {
            return DateUtils.getRelativeTimeSpanString(timestamp * 1000L).toString();
        }
    }

    public static String refundStatus(String status) {
        if (TextUtils.isEmpty(status)) {
            return "";
        }
        switch (status) {
            case "0":
                return "已充值押金";
            case "1":
                return "审核中";
            case "2":
                return "打款中";
            case "3":
                return "已退款";
            case "4":
                return "已拒绝";
            default:
                return "";
        }
    }

    //跳转货拉拉小程序
    public static void weChatMiniProgram(Context context) {
        IWXAPI api = WXAPIFactory.createWXAPI(context, Constants.APP_ID);

        if (!api.isWXAppInstalled()) {
            ToastUtil.show("请先安装微信");
            return;
        }
        WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
        req.userName = "gh_6b18e73b21cd"; // 填小程序原始id,非小程序的 AppID
//req.path = path;                  //拉起小程序页面的可带参路径，不填默认拉起小程序首页，对于小游戏，可以只传入 query 部分，来实现传参效果，如：传入 "?foo=bar"。
        req.miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE;// 可选打开 开发版，体验版和正式版
        api.sendReq(req);
    }

    public static String setRanking(int i) {
        switch (i) {
            case 1:
                return "较差";
            case 3:
                return "一般";
            case 5:
                return "良好";
            case 7:
                return "优秀";
            default:
                return "";
        }
    }

    public static String getPromotionType(String type) {
        switch (type) {
            case "1":
                return "金卡-年卡";
            case "2":
                return "金卡-半年卡";
            case "3":
                return "金卡-季卡";
            case "6":
                return "银卡-年卡";
            case "7":
                return "银卡-半年卡";
            case "8":
                return "银卡-季卡";
            default:
                return "";
        }
    }

    public static void getAbnormalStatus(TextView textView, String status) {
        if (TextUtils.isEmpty(status)) {
            textView.setText("驳回");
            textView.setTextColor(Color.parseColor("#D9001B"));
            return;
        }
        switch (status) {
            case "2":
            case "1":
                textView.setText("");
                break;
            case "3":
                textView.setText("驳回");
                textView.setTextColor(Color.parseColor("#D9001B"));
                break;
            case "5":
                textView.setText("同意");
                textView.setTextColor(Color.parseColor("#00AA3A"));
                break;
            case "7":
                textView.setText("已打款");
                textView.setTextColor(Color.parseColor("#00AA3A"));
                break;
            case "9":
                textView.setText("已撤销");
                textView.setTextColor(Color.parseColor("#000000"));
                break;
        }
    }

    public static String getScoreGrade(double parseDouble) {
        if (parseDouble <= 1) {
            return "极差";
        } else if (parseDouble > 1 && parseDouble <= 2) {
            return "差";
        } else if (parseDouble > 2 && parseDouble <= 3) {
            return "一般";
        } else if (parseDouble > 3 && parseDouble <= 4) {
            return "好";
        } else {
            return "很好";
        }
    }


    public static String format2(double value) {

        long l = (long) (value * 10);
        double d = l / 10D;

        return String.valueOf(d);
    }


    public static String getGrade(float parseFloat) {
        if (parseFloat > 100) {
            return "优秀";
        } else if (parseFloat > 80) {
            return "良好";
        } else if (parseFloat > 60) {
            return "一般";
        } else if (parseFloat > 40) {
            return "较差";
        } else if (parseFloat > 0) {
            return "极差";
        } else {
            return "-";
        }
    }

    public static String getInfluence(float parseFloat) {
        if (parseFloat > 100) {
            return "正常到账｜ 正常接单｜正常抢单｜正常得红包";
        } else if (parseFloat > 80) {
            return "正常到账｜正常接单｜ 正常抢单｜正常得红包";
        } else if (parseFloat > 60) {
            return "正常到账｜正常接单｜正常抢单｜不再得红包";
        } else if (parseFloat > 40) {
            return "延长至7天到账｜能接单｜能抢单｜完成订单不再得到红包";
        } else if (parseFloat > 0) {
            return "延长至30天到账丨每天限制5单丨完成订单不再得到红包";
        } else {
            return "账户冻结";
        }
    }

    public static String behavior(String money03) {
        double value = Double.parseDouble(money03);
        if (value > 120) {
            return "120";
        } else {
            return checkPoint(money03);
        }
    }

    /**
     * @param urlStr    url字符串。
     * @param paramName 指定参数名称。
     * @return NA.
     * @desc 获取url中指定参数的值。
     */
    public static String readValueFromUrlStrByParamName(String urlStr, String paramName) {
        if (urlStr != null && urlStr.length() > 0) {
            int index = urlStr.indexOf("?");
            String temp = (index >= 0 ? urlStr.substring(index + 1) : urlStr);
            String[] keyValue = temp.split("&");
            String destPrefix = paramName + "=";
            for (String str : keyValue) {
                if (str.indexOf(destPrefix) == 0) {
                    return str.substring(destPrefix.length());
                }
            }
        }
        return null;
    }

    public static String billType(String type, String num) {
        switch (type) {
            case "money01":
                if (Double.parseDouble(num) < 0) {
                    return "零钱支付";
                } else {
                    return "";
                }
            case "money02":
                if (Double.parseDouble(num) > 0) {
                    return "任务红包";
                } else {
                    return "红包抵扣";
                }
            case "weipay_mini":
            case "weipay_app":
                return "微信支付";
            case "alipay_app":
                return "支付宝支付";
            case "cash":
                return "现金支付";
            default:
                return "";
        }
    }
}
